import { Col, Form, Upload } from 'antd';
import { RcFile } from 'antd/es/upload';
import { API } from "@request/api"
interface FormItemUploadProps {
    name: string,
    label: string,
    filelist: any[],
    onUpload:Function
}
const FormItemUpload = (props: FormItemUploadProps) => {
    const handlerBeforeUploadFile = (file: RcFile): boolean => {
        // API.uoloadFile(file).then(e => {
        //     form.setFieldValue("url", e);
        // });
        props.onUpload();
        return false;
    }
    return (
        <Col style={{margin:"16px 0"}}>
        <Form.Item name={props.name} required={true} label={props.label}>
            <Upload
                name="file"
                listType="picture-card"
                className="avatar-uploader"
                action="http://127.0.0.1/api/v1/service/auth/upload"
                // fileList={props.filelist}
                beforeUpload={handlerBeforeUploadFile}
            >
                {'上传'}
            </Upload>
        </Form.Item>
        </Col>
        
    )


}
export default FormItemUpload;
export type { FormItemUploadProps };